<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>新增角色</title>
		<%@ include file="../../common/Admin-list.jsp"%>  
		<script type="text/javascript" src="<%=bpath %>Scripts/jquery/jquery.form.js"></script> 	     
		<script type="text/javascript">					
		$(function(){
			var subUrl="../AdminRoleType/save.json";			
			if('${data.type}'!=null&&'${data.type}'=="edit"){ //修改				
				$("#lblTitle").html('修改-${data.admin_RoleType.roleName}');				
				if('${data.admin_RoleType.status}'=="0"){
					$("#status").attr("checked",false);
				}
				
				if('${data.admin_RoleType.isAdmin}'=="1"){
					$("#isAdmin").attr("checked",true);
				}
				
				$("#id").val('${data.admin_RoleType.id}');				
				$("#roleName").val('${data.admin_RoleType.roleName}');
				
				subUrl="../AdminRoleType/update.json";
			}	
						
			//保存
			$("#lnbSave").click(function(){								
				$("#addForm").ajaxSubmit({
					url:subUrl,
					type:"POST",
					beforeSubmit:checkForm,
					contentType:"application/x-www-form-urlencoded;charset=UTF-8",
					error:function(){},
					success:function(data){
						if(data.success==true){
							showTip("保存成功，返回列表页面！","succeed");					    	
						}else{
							//showTip("操作失败","warning");  
							art.dialog.alert('保存失败，请确认填写正确！');
						}
					},
				});
			});
		});
			
		function checkForm(){
			if($("#isAdmin").is(':checked')){
				$('#isAdmin').val(1);
			}
			var flag=$('#addForm').form('validate');
			return true;
		}
				
		//消息提示  
		function showTip(mess,icon) {  
		    art.dialog({  
		        id : 'Tip',  
		        title : '消息',  
		        fixed : true,  
		        lock : true,  
		        opacity: .2,  
		        content : mess,  
		        icon : icon,  
		        time : 1  
		    });  
		    setTimeout('originReload()', 1000);  
		}  
		
		//重载来源页面  
		function originReload(){  
		    var win = art.dialog.open.origin;		    
		    win.location.reload();  
		}		
		</script>
	</head>
<body>
<div>  
	<div id="tab">
	    <ul>
	        <li class="Current">
	        	<a href="#" ><span id="lblTitle">新增角色</span></a>
	        </li>
	    </ul>
	</div>
    <div id="menu">
		<ul>        	
            <li>
            	<a id="lnbSave">
            		<span><img src="<%=basePath %>pages/Admin/Images/Icon/save.gif" alt="Save" />保存</span>
            	</a>            	
           </li>
        </ul>
    </div>    
    <div id="middle">
    <form action="../AdminRoleType/save.json" id="addForm" name="addForm" method="post" >    
    <div class="editor">
        <table class="eTable">
            <tbody>
            <tr class="eTr">
                <td class="name">
                    <span>启用</span>
                </td>
                <td>
                	<span style="margin:0 0 0 -3px">
                    	<input id="status" type="checkbox" name="status" checked="checked" value="1"/>
                    	<label for="status">启用</label>
                    </span>
                </td>
            </tr>
            <tr class="eTr">
                <td class="name">
                    <span>管理员</span>
                </td>
                <td>
                	<span style="margin:0 0 0 -3px">
                    	<input id="isAdmin" type="checkbox" name="isAdmin" />
                    	<label for="isAdmin">网站管理员</label>
                    </span>
                </td>
            </tr>
            <tr class="eTr">
                <td class="name">
                    <span>角色名称</span></td>
                <td>
                    <input name="roleName" type="text" id="roleName" class="input" />
                    <input id="id" name="id" type="hidden" ></input>
                </td>
            </tr>           
        </tbody>
        </table>
    </div>
	</form>
    </div>    
   </div>
</body>
</html>